Fix the detection of directories when listing files using libgit2
authorIvan Ukhov <ivan.ukhov@gmail.com>
Sat, 30 May 2015 12:48:25 +0000 (08:48 -0400)
committerIvan Ukhov <ivan.ukhov@gmail.com>
Tue, 2 Jun 2015 14:55:04 +0000 (10:55 -0400)
Cargo.lock
Cargo.toml
src/cargo/lib.rs
src/cargo/sources/path.rs

index f567d62b3f14d7c928d77f0aac05e306858e37b0..7639e26d1a22c5a2e2f016dd7be141991a90b1ad 100644 (file)
@@ -14,6 +14,7 @@ dependencies = [
  "hamcrest 0.1.0 (git+https://github.com/carllerche/hamcrest-rust.git)",
  "kernel32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libgit2-sys 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "num_cpus 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "regex 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)",
index 7549de414ac5b070e07ed291d449e19fe5386189..c9323fb8eaa2a59bed24985c5a208ffc6584c9f0 100644 (file)
@@ -18,6 +18,7 @@ git2 = { version = "0.2", features = ["unstable"] }
 git2-curl = "0.2"
 glob = "0.2"
 libc = "0.1"
+libgit2-sys = "0.2"
 log = "0.3"
 num_cpus = "0.1"
 regex = "0.1"
index 3a47f1eac5f5f2c5e838915a4a6371aec026a8f6..e9c98355b5e3103af90bef19e8e55878fb2d4a97 100644 (file)
@@ -10,6 +10,7 @@ extern crate flate2;
 extern crate git2;
 extern crate glob;
 extern crate libc;
+extern crate libgit2_sys;
 extern crate num_cpus;
 extern crate regex;
 extern crate registry;
index f9f33b8eca44ed29f682789b4afaa075df00b365..d1f6f97fade023dcbb029e5b71ec8abd6ac8552b 100644 (file)
@@ -6,7 +6,6 @@ use std::path::{Path, PathBuf};
 
 use git2;
 use glob::Pattern;
-use libc;
 
 use core::{Package, PackageId, Summary, SourceId, Source, Dependency, Registry};
 use ops;
@@ -147,8 +146,8 @@ impl<'cfg> PathSource<'cfg> {
         // the untracked files are often part of a build and may become relevant
         // as part of a future commit.
         let index_files = index.iter().map(|entry| {
-            let is_dir = entry.mode & (libc::S_IFMT as u32) ==
-                                      (libc::S_IFDIR as u32);
+            use libgit2_sys::git_filemode_t::GIT_FILEMODE_COMMIT;
+            let is_dir = entry.mode == GIT_FILEMODE_COMMIT as u32;
             (join(&root, &entry.path), Some(is_dir))
         });
         let mut opts = git2::StatusOptions::new();